package com.iu.eblood.daoImpl;

import java.util.ArrayList;
import java.util.List;

import javax.management.Query;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.iu.eblood.dao.GenericDao;
import com.iu.eblood.daoInterfaces.EventUserResponseDao;
import com.iu.eblood.model.Event;
import com.iu.eblood.model.Eventuserresponse;
import com.iu.eblood.model.Informativemessage;
import com.iu.eblood.model.User;

@Repository("EventUserResponseDaoImpl")
public class EventUserResponseDaoImpl  extends GenericDao<Eventuserresponse,Long>
implements EventUserResponseDao{

	public EventUserResponseDaoImpl() {
	super(Eventuserresponse.class);
	}

	
	public List<Event> participatedEvent(User user) {
		
		Session session=getHibernateTemplate().getSessionFactory().getCurrentSession();
	List<Event> erp=session.createQuery("select eur.event from Eventuserresponse as eur where eur.task.taskid!=:task and eur.user=:user")
		.setLong("task",0L).setEntity("user",user).list();
		
		
//		Criteria c=session.
//				createCriteria(Eventuserresponse.class).
//				add(Restrictions.and(
//						Restrictions.eq("task.taskid",0L),
//						Restrictions.eq("user", user)));
//		
		
		return erp;
	}
	
	
	
}
